export const pieChartConfig = () => {
  const colors = [
    "#05D0F9FF",
    "#187AEBFF",
    "#D0DBE1FF",
    "#E8BA65FF",

    "#6DD1EAFF",
    "#1978E5FF",
    "#ECB205FF",
    "#9C30F1FF",
    "#7BC17FFF",
    "#E8BA65FF",
  ];
  let x = [
    "玄武区",
    "秦淮区",
    "建邺区",
    "鼓楼区",
    "雨花台区",
    "栖霞区",
    "江宁区",
    "浦口区",
    "六合区",
    "溧水区",
    "高淳区",
    "江北新区",
  ];
  let y = [80, 159, 61, 165, 41, 71, 111, 41, 90, 73, 56, 74];
  const total = y.reduce((a,b)=>a+b)
  const data = x.map((item,index) => {
    const piec =  y[index]/total*100
    return {
      value: piec.toFixed(2),
      name: item,
    };
  })
  const option = {
    color: colors,
    tooltip: {
      trigger: "item",
      zlevel: 1,
      axisPointer: {
        lineStyle: {
          color: "rgba(255,255,255,.5)",
        },
      },
      backgroundColor: "rgba(33, 51, 67, 1)",
      borderColor: "rgba(255,255,255,0)",
      textStyle: {
        color: "#fff",
      },
      formatter: (params, ticket, callback) => {
        if (params.name) {
          return `${params.name}:${params.value}%`;
        }
      },
    },
    series: [
      {
        type: "pie",
        radius: "55%",
        center: ["50%", "50%"],
        data: data,
        roseType: "radius",
        label: {
          color: "rgba(255, 255, 255, 1)",
          formatter: "{a|{b}}{b|{d}%}  ",
          rich: {
            a: {
              color: "#999",
              align: "center",
            },
            b: {
              fontSize: 14,
            },
          },
        },
        labelLine: {
          lineStyle: {
            color: "rgba(255, 255, 255, 0.3)",
          },
          smooth: 0.2,
          length: 10,
          length2: 15,
        },
        itemStyle: {
          shadowBlur: 200,
          shadowColor: "rgba(0, 0, 0, 0.5)",
        },
        animationType: "scale",
        animationEasing: "elasticOut",
        // animationDelay: function (idx) {
        //   return Math.random() * 200;
        // },
      },
    ],
  };

  return option;
};
